package com.quanshu.shop.goods.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.google.android.flexbox.AlignSelf;
import com.google.android.flexbox.FlexboxLayout;
import com.google.android.flexbox.FlexboxLayoutManager;
import com.quanshu.exchange.R;
import com.quanshu.shop.goods.entity.GoodsPropetyChildEntity;

import java.util.List;

/**
 * 作者  李哲
 * 创建时间 2018/7/26
 * 邮箱 lizhetongliao@163.com
 * 说明
 **/
public class GoodsPropertyChildAdapter extends BaseQuickAdapter<GoodsPropetyChildEntity, BaseViewHolder> {
    private Context mContext;

    public GoodsPropertyChildAdapter(Context mContext, @Nullable List<GoodsPropetyChildEntity> data) {
        super(R.layout.item_goods_propety_child, data);
        this.mContext = mContext;
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsPropetyChildEntity item) {
        helper.setText(R.id.item_goods_property_child_txt, item.getName());
        if (item.isSelect()) {
            helper.getView(R.id.item_goods_property_child_txt).setEnabled(false);
        } else {
            helper.getView(R.id.item_goods_property_child_txt).setEnabled(true);
        }
        helper.addOnClickListener(R.id.item_goods_property_child_txt);
        ViewGroup.LayoutParams layoutParams = helper.getView(R.id.item_goods_property_child_txt).getLayoutParams();
        if (layoutParams instanceof FlexboxLayout.LayoutParams) {
            FlexboxLayoutManager.LayoutParams layoutParams1 = (FlexboxLayoutManager.LayoutParams) layoutParams;
            layoutParams1.setFlexGrow(1.0f);
            layoutParams1.setAlignSelf(AlignSelf.FLEX_END);
        }
    }
}
